-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: include "vitest" in the process name #4191
feat: include "vitest" in the process name #4191
Conversation
Run & review this pull request in StackBlitz Codeflow. |
✅ Deploy Preview for fastidious-cascaron-4ded94 canceled.
|
@AriPerkkio what do you think? |
packages/vitest/src/node/cli.ts
Outdated
@@ -167,6 +167,8 @@ function normalizeCliOptions(argv: CliOptions): CliOptions { | |||
} | |||
|
|||
async function start(mode: VitestRunMode, cliFilters: string[], options: CliOptions): Promise<Vitest | undefined> { | |||
process.title = 'node (vitest)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bun doesn't support changing title yet, but to be future proof we can do process.title += ' (vitest)'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.title
can not be longer than the original title:
https://nodejs.org/api/process.html#processtitle
on Linux and macOS, process.title is limited to the size of the binary name plus the length of the command-line arguments because setting the process.title overwrites the argv memory of the process
So I assume +=
will likely crash the runtime on affected platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how it will do that from the comment you linked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or are you saying that process.title
already fulfills these requirements before reassigning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From manual testing it looks like that title cannot be longer than node {filename}
- in our case it's probably(?) node vitest.mjs
.
When running Vitest, I wasn't able to come up with the name that would not fit in the activity monitor. If you just have a simple file, the limit is reached pretty fast:
process.title = 'node (vitest)'
setTimeout(() => {}, 5000)
node t.mjs
Activity monitor shows:
node (vite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Activity monitor shows:
node (vite
Would vitest (node)
be better? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This problem exists only for this custom file due to the short name. Vitest doesn't have this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for my debugging workflow. 👍
Without the node
prefix it would not show in pgrep node
so having that is great. We should also add this to entrypoints of node:child_process
, e.g. packages/vitest/src/runtime/child.ts
Why not just |
Because people look for the "node" process usually. This is why I asked @AriPerkkio opinion here (this change was discussed in a team meeting) |
If your tests spawn external processes you won't see those if you look for process.title = "vitest";
setTimeout(() => {}, 5000);
This works: process.title = "node (vitest)";
setTimeout(() => {}, 5000);
|
I prefer
|
Also, what if vitest is run in another runtime like |
This should not be a problem because:
|
It will eventually and then you'll have to needlessly change the process name again. I still think |
Description
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.